package com.osce.score.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csce.domain.entity.score.ScoreExExamPlaceAllot;
import com.csce.domain.entity.score.ScoreExExamSession;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 考试分配学员Mapper接口
 *
 * @author zzx
 * @since 2023-09-07
 */
@Repository
public interface ScoreExExamPlaceAllotMapper extends BaseMapper<ScoreExExamPlaceAllot> {

    /**
     * 查询考试分配学员
     *
     * @param id 考试分配学员主键
     * @return 考试分配学员
     */
    ScoreExExamPlaceAllot selectScoreExExamPlaceAllotById(Long id);

    /**
     * 查询考试分配学员列表
     *
     * @param scoreExExamPlaceAllot 考试分配学员
     * @return 考试分配学员集合
     */
    List<ScoreExExamPlaceAllot> selectScoreExExamPlaceAllotList(ScoreExExamPlaceAllot scoreExExamPlaceAllot);

    /**
     * 新增考试分配学员
     *
     * @param scoreExExamPlaceAllot 考试分配学员
     * @return 结果
     */
    int insertScoreExExamPlaceAllot(ScoreExExamPlaceAllot scoreExExamPlaceAllot);

    /**
     * 修改考试分配学员
     *
     * @param scoreExExamPlaceAllot 考试分配学员
     * @return 结果
     */
    int updateScoreExExamPlaceAllot(ScoreExExamPlaceAllot scoreExExamPlaceAllot);

    /**
     * 删除考试分配学员
     *
     * @param id 考试分配学员主键
     * @return 结果
     */
    int deleteScoreExExamPlaceAllotById(Long id);

    /**
     * 批量删除考试分配学员
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteScoreExExamPlaceAllotByIds(Long[] ids);


    /**
     * 批量删除考试分配学员
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteScoreExExamPlaceAllotBySessionIds(Long[] ids);

    /**
     * 批量新增考试分配学员
     *
     * @param scoreExExamPlaceAllotList 考试分配学员列表
     * @return 结果
     */
    int batchScoreExExamPlaceAllot(List<ScoreExExamPlaceAllot> scoreExExamPlaceAllotList);


    /**
     * 通过考试场次主键删除考试分配学员信息
     *
     * @param id 考试场次ID
     * @return 结果
     */
    int deleteScoreExExamPlaceAllotBySessionId(Long id);

    int insertScoreExExamPlaceAllotBySession(List<ScoreExExamSession> sessions);

    List<String> selectCodeByExamIdGroupAndOrderByCode(Long id);

    int updateUserIdByCode(@Param("examId") Long examId, @Param("code") String code, @Param("userId") Long userId);

    int updateUserIdNullByExam(Long examId);

    int planUserCountByExamId(Long examId);

    ScoreExExamPlaceAllot selectScoreExExamPlaceAllotBySession(@Param("examId") String examId, @Param("timeId") String timeId, @Param("placeId") String placeId, @Param("code") String code);
}
